package cn.mgr.logistics.activity;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
import cn.mgr.logistics.webservice.CommonWebservice;

public class ContactUsActivity extends Activity {
	private Button firstBtn;
	private Button secondBtn;
	private TextView title;

	private Button contactBtn;

	private CommonWebservice commonWebservice;
	private String companyTel;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.contact_us);
		firstBtn = (Button) findViewById(R.id.first_btn);
		secondBtn = (Button) findViewById(R.id.second_btn);
		title = (TextView) findViewById(R.id.header_title);
		secondBtn.setVisibility(View.INVISIBLE);
		firstBtn.setText(getString(R.string.back));
		title.setText(getString(R.string.contact_us));

		contactBtn = (Button) findViewById(R.id.contact_us);

		firstBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
		});

		companyTel = getString(R.string.company_tel);

		contactBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"
						+ companyTel));
				startActivity(intent);
			}
		});

		new Thread(new Runnable() {

			@Override
			public void run() {
				commonWebservice = new CommonWebservice();
				companyTel = commonWebservice.getCompanyTel();
				if (companyTel == null) {
					companyTel = getString(R.string.company_tel);
				}
			}
		}).start();
	}

}
